<?php
class App_Source_Articles_Validator extends Mozg_Property_Validator
{
	protected function ValidateTitle($value)
	{
		return strlen($value);
	}

	protected function ValidateUrl($url)
	{
		$obj = $this->GetData();
		if ($obj->GetBlogId()) return true;

		if (!preg_match('/^[a-z_\-0-9]+$/uis', $url))
		{
			return false;
		}

		if (Mozg_Mapper::Get('Articles')->CheckUrl($obj->GetId(), $obj->GetUrl()))
		{
			$this->SetErrorMessage('url', Mozg_Lang::_('URL_ALREADY_EXISTS'));
			return false;
		}

		return true;
	}
}